﻿using System.Windows;
using Common.Utils;
using Gao.Poker.Domain;
using Gao.Poker.Services;
using MessageBox = Xceed.Wpf.Toolkit.MessageBox;

namespace Gao.Poker.App.Sys
{
    /// <summary>
    /// Interaction logic for ModifyPwd.xaml
    /// </summary>
    public partial class ModifyPwd : Window
    {
        public User _user;

        public ModifyPwd()
        {
            InitializeComponent();
        }

        public User User
        {
            get { return _user; }
            set
            {
                _user = value;
                if (value != null) txtUserName.Text = value.UserName;
            }
        }

        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            if(txtPwd.Password != txtPwdAgain.Password)
            {
                MessageBox.Show("第二次输入的密码和第一次输入的不一致","提示信息");
                return;
            }

            User.Password = EncryptHelper.Md5(txtPwd.Password);
            UserService.Instance().Save(User);

            MessageBox.Show("修改成功", "提示信息");
            Close();
        }
    }
}
